//
//  SynthesizeDetailsViewController.m
//  XDBaseFrameWork
//
//  Created by XD-XY on 10/20/14.
//  Copyright (c) 2014 XD-XY. All rights reserved.
//

#import "SynthesizeDetailsViewController.h"

#import "ChooseTaoCanViewController.h"

#import "SynDetailsSecondCell.h"
#import "SynDetailFourthCell.h"
#import "SynDetailsSixthCell.h"

#import "StarCell.h"

#import "OrderConfirmViewController.h"

#import "MJPhoto.h"
#import "MJPhotoBrowser.h"
#import "UIImageView+MJWebCache.h"
#import "CommentListViewController.h"

#import "ShowWebViewController.h"

#import "ShowRecommendWebViewController.h"

#define backTime 0.25f
#define SHAREHEIGHT      205

@interface SynthesizeDetailsViewController ()
{
    UIButton * rightBtn;
    UIView * headView;
    UIView * footview;
    UITableView * mTableView;
    
    UILabel * footPriceLB;
    
    UIView * lview;
    
    NSMutableArray * SeriesInfoArray;   //套餐信息
    NSMutableArray * PhotoListArray;    //小图片
    NSMutableDictionary * EmplInfoDict; //摄影师信息
    NSMutableDictionary * persentSeriesDict; //选中的套餐信息
        
    //下面都是规格页面的元素
    UIView * guiGeView;
    
    UIView * oneView;
    UIView * twoView;
    UIView * threeView;
    
    UIImageView * gworkIV;
    UILabel * gworkNameLB;
    UILabel * gworkPriceLB;
    UILabel * gworkMarketPriceLB;
    
    UIImageView * gemplIV;
    UILabel * gemplNameLB;
    UIImageView * grenzhenIV;
    UILabel * gjiebieLB;
    UILabel * gorderCountLB;
    UILabel * gemplcollectLB;
    
    NSString * zString;
    NSString * xString;
    BOOL iscollcetion;
    int collectioncount;
}
@end

@implementation SynthesizeDetailsViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.titleLabel.text = @"综合详情";
    iscollcetion = NO;
    zString = [[NSString alloc] init];
    xString = [[NSString alloc] init];
    zString = @"4组造型";
    xString = @"要相册";
    
    SeriesInfoArray = [[NSMutableArray alloc] init];   //套餐信息
    PhotoListArray = [[NSMutableArray alloc] init];    //小图片
    EmplInfoDict = [[NSMutableDictionary alloc] init]; //摄影师信息
    persentSeriesDict = [[NSMutableDictionary alloc] init]; // 选中的套餐信息
    
    rightBtn = [self createButtonOnNavigationWithRect:CGRectMake(UI_SCREEN_WIDTH-50-44, 0,40, 44) normalImg:LOADIMAGE(@"i3@2x") highlightImg:LOADIMAGE(@"i3@2x")];
    [rightBtn setTitleColor:self.titleLabel.textColor forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(rightBtnCick) forControlEvents:UIControlEventTouchUpInside];
    [self.navigationBarView addSubview:rightBtn];
    
    [self initViews];
    
    [self initShareView];
    
    [self initGuigeViews];
    
    [self getDatas];
}

#pragma mark
#pragma mark UI 布局
-(void)initViews
{
    float h1 = 0;
    float x = UI_SCREEN_WIDTH-44;
    if (IOS7) {
        h1 = 20;
    }
    
    UIButton * shareBtn = [UIButton initButton:CGRectMake(x, h1, 44, 44) btnNorImage:[UIImage imageNamed:@"share"] btnHighlightImage:nil btnTitle:nil titleColor:nil titleFont:nil];
    [shareBtn addTarget:self action:@selector(handleAlphaView) forControlEvents:UIControlEventTouchUpInside];
    [self.navigationBarView addSubview:shareBtn];
    
    
    mTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, self.contentView.frame.size.height-49) style:UITableViewStylePlain];
    mTableView.backgroundColor = [UIColor clearColor];
    mTableView.delegate = self;
    mTableView.dataSource = self;
    mTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.contentView addSubview:mTableView];
    
    [self initHeadViews];
    
    mTableView.tableHeaderView = headView;
    
    [self initFootViews];
    
    mTableView.hidden =YES;
    footview.hidden = YES;
}


#pragma mark
#pragma mark UITableView 头部
-(void)initHeadViews
{
    headView = [UIView initViewRect:CGRectMake(0, 0, UI_SCREEN_WIDTH,30) andBackGroudColor:[UIColor whiteColor]];
//    UIImageView * headIV = [UIImageView initImageViewRect:CGRectMake(0, 0, UI_SCREEN_WIDTH, 140) andImage:nil andUserInteractionEnabled:YES];
//    headIV.backgroundColor = UIColorFromRGB(0xdcdcdc);
//    headIV.tag = 1001;
//    [headView addSubview:headIV];
    
    UILabel * NameLabel = [UILabel initLabelText:@"" andRect:CGRectMake(17, 0, UI_SCREEN_WIDTH-10, 30) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:16] andTextColor:UIColorFromRGB(0x626262) andTextAlignment:NSTextAlignmentLeft];
    NameLabel.tag = 1002;
    [headView addSubview:NameLabel];
    
//    UIButton * otherLB = [UILabel initLabelText:@"其他套餐" andRect:CGRectMake(236,0, 80, NameLabel.frame.size.height) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:15] andTextColor:UIColorFromRGB(0x929292) andTextAlignment:NSTextAlignmentLeft];
//    otherLB.tag = 1003;
//    [headView addSubview:otherLB];
//    
////    UIImageView * arrowIV = [UIImageView initImageViewRect:CGRectMake(300,height_y(headIV)+7.5, 8, 15) andImage:LOADIMAGE(@"right_arrows@2x") andUserInteractionEnabled:YES];
////    [headView addSubview:arrowIV];
////    
////    UIButton * otherBtn = [UIButton initButton:otherLB.frame btnImage:nil btnTitle:nil];
////    [otherBtn addTarget:self action:@selector(chooseOtherTaoCan) forControlEvents:UIControlEventTouchUpInside];
////    [headView addSubview:otherBtn];
}

#pragma mark
#pragma mark footview 布局
-(void)initFootViews
{
    footview = [UIView initViewRect:CGRectMake(0,self.contentView.frame.size.height-49, UI_SCREEN_WIDTH, 50) andBackGroudColor:UIColorFromRGB(0xf1f1f1)];
    [self.contentView addSubview:footview];
    
    footPriceLB = [UILabel initLabelText:@"" andRect:CGRectMake(15,0, 200, 50) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:22] andTextColor:UIColorFromRGB(0xff6800) andTextAlignment:NSTextAlignmentLeft];
    [footview addSubview:footPriceLB];
    
    UIButton * sureBtn = [UIButton initButton:CGRectMake(UI_SCREEN_WIDTH-111-10,9, 111,32) btnImage:LOADIMAGE(@"surexiadanbtn@2x") btnTitle:@"确认下单" titleColor:[UIColor whiteColor] titleFont:[UIFont systemFontOfSize:16]];
    [sureBtn addTarget:self action:@selector(sureBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [footview addSubview:sureBtn];
}

#pragma mark
#pragma mark 规格页面 布局
-(void)initGuigeViews
{
    guiGeView = [UIView initViewRect:CGRectMake(UI_SCREEN_WIDTH, 0, self.view.frame.size.width, self.view.frame.size.height) andBackGroudColor:mClearColor];
    [self.view addSubview:guiGeView];
    
    UIView * view = [UIView initViewRect:guiGeView.bounds andBackGroudColor:RGBA(0, 0, 0, 0.4)];
    [guiGeView addSubview:view];
    
    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(guiGeViewBack:)];
    [view addGestureRecognizer:tap];
    
    UISwipeGestureRecognizer * tap1 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(guiGeViewBack:)];
    [tap1 setDirection:UISwipeGestureRecognizerDirectionRight];
    [view addGestureRecognizer:tap1];
    
    UIView * view2 = [UIView initViewRect:CGRectMake(43, 0,guiGeView.frame.size.width-43, guiGeView.frame.size.height) andBackGroudColor:UIColorFromRGB(0xf1f1f1)];
    [guiGeView addSubview:view2];
    
    UISwipeGestureRecognizer * tap2 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(guiGeViewBack:)];
    [tap2 setDirection:UISwipeGestureRecognizerDirectionRight];
    [view2 addGestureRecognizer:tap2];
    
    CGFloat xheight = IOS7?20:0;
    oneView = [UIView initViewRect:CGRectMake(0,0, view2.frame.size.width,60+xheight) andBackGroudColor:[UIColor whiteColor]];
    [view2 addSubview:oneView];
    
    gworkIV = [UIImageView initImageViewRect:CGRectMake(18, 10+xheight,46,46) andImage:nil andUserInteractionEnabled:YES];
    gworkIV.backgroundColor = UIColorFromRGB(0xdcdcdc);
    [oneView addSubview:gworkIV];
    
    gworkNameLB = [UILabel initLabelText:@"百天照到家拍3组造型1个相册" andRect:CGRectMake(width_x(gworkIV)+6,gworkIV.frame.origin.y, UI_SCREEN_WIDTH-(width_x(gworkIV)+10), 15) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:15] andTextColor:UIColorFromRGB(0x4a4a4a) andTextAlignment:NSTextAlignmentLeft];
    [oneView addSubview:gworkNameLB];
    
    gworkPriceLB = [UILabel initLabelText:@"" andRect:CGRectMake(gworkNameLB.frame.origin.x,height_y(gworkNameLB)+10, 160, 20) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:20] andTextColor:UIColorFromRGB(0xff6800) andTextAlignment:NSTextAlignmentLeft];
    [oneView addSubview:gworkPriceLB];
    
    CGRect rect1 = [XDTools autoSizeOftext:gworkPriceLB.text andSize:CGSizeMake(200, 22.0f) andtextFont:22.0f];
    gworkPriceLB.frame =CGRectMake(gworkNameLB.frame.origin.x,height_y(gworkNameLB)+10,rect1.size.width, 22);
    
    gworkMarketPriceLB = [UILabel initLabelText:@"" andRect:CGRectMake(width_x(gworkPriceLB)+8,gworkPriceLB.frame.origin.y+5, 150, 14) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:14] andTextColor:UIColorFromRGB(0xadadad) andTextAlignment:NSTextAlignmentLeft];
    [oneView addSubview:gworkMarketPriceLB];
    
    CGRect rect2 = [XDTools autoSizeOftext:gworkMarketPriceLB.text andSize:CGSizeMake(200, 15.0f) andtextFont:15.0f];
    
    lview = [UIView initViewRect:CGRectMake(gworkMarketPriceLB.frame.origin.x,gworkMarketPriceLB.center.y, rect2.size.width+4, 1) andBackGroudColor:UIColorFromRGB(0x929292)];
    [oneView addSubview:lview];
    
    
    
    twoView = [UIView initViewRect:CGRectMake(0, height_y(oneView), view2.frame.size.width, 59) andBackGroudColor:[UIColor whiteColor]];
    [view2 addSubview:twoView];
    
    UIImageView * shortXulong = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,UI_SCREEN_WIDTH,.5f)];
    shortXulong.image = [UIImage imageNamed:@"xuxian_short@2x"];
    [twoView addSubview:shortXulong];
    
    gemplIV = [UIImageView initImageViewRect:CGRectMake(18,9, 42, 42) andImage:nil andUserInteractionEnabled:YES];
    gemplIV.image = LOADIMAGE(@"placeholderHeader@2x");
    gemplIV.layer.masksToBounds = YES;
    gemplIV.layer.cornerRadius = 21;
    [twoView addSubview:gemplIV];
    
    gemplNameLB = [UILabel initLabelText:@"老王" andRect:CGRectMake(width_x(gemplIV)+9,7,80,5+5+15) andBackGroudColor:[UIColor clearColor] andTextFont:[UIFont systemFontOfSize:15] andTextColor:UIColorFromRGB(0x4a4a4a) andTextAlignment:NSTextAlignmentLeft];
    [twoView addSubview:gemplNameLB];
    
    ///计算名字长度
    CGRect rect3 = [XDTools autoSizeOftext:gemplNameLB.text andSize:CGSizeMake(200,15) andtextFont:15.0f];
    gemplNameLB.frame = CGRectMake(width_x(gemplIV)+15,7,rect3.size.width,5+5+15);
    
    if (1) {
        grenzhenIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"renzheng"]];
        grenzhenIV.frame = CGRectMake(width_x(gemplNameLB)+5, 13.5,14,14);
        [twoView addSubview:grenzhenIV];
    }
    
    gjiebieLB = [UILabel initLabelText:@"资深摄影师" andRect:CGRectMake(width_x(gemplNameLB)+23,12, 140, 5+11+5) andBackGroudColor:[UIColor clearColor] andTextFont:[UIFont systemFontOfSize:11] andTextColor:UIColorFromRGB(0x929292) andTextAlignment:NSTextAlignmentLeft];
    [twoView addSubview:gjiebieLB];
    
    UIImageView * shortXuXian = [[UIImageView alloc] initWithFrame:CGRectMake(width_x(gemplIV)+8, height_y(gemplNameLB), UI_SCREEN_WIDTH-9-11-(width_x(gemplIV)), .5f)];
    shortXuXian.image = [UIImage imageNamed:@"xuxian_long"];
    [twoView addSubview:shortXuXian];

    UIImageView * ordercountIV = [UIImageView initImageViewRect:CGRectMake(width_x(gemplIV)+8, height_y(gemplNameLB)+5, 8, 10) andImage:LOADIMAGE(@"orderNum@2x") andUserInteractionEnabled:NO];
    [twoView addSubview:ordercountIV];
    
    
    gorderCountLB = [UILabel initLabelText:@"35单" andRect:CGRectMake(width_x(ordercountIV)+3,ordercountIV.frame.origin.y-0.5 , 100, 11) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:11] andTextColor:UIColorFromRGB(0x9d9d9d) andTextAlignment:NSTextAlignmentLeft];
    [twoView addSubview:gorderCountLB];
    
    UIImageView * clloctionIV = [UIImageView initImageViewRect:CGRectMake(width_x(gemplIV)+54, ordercountIV.frame.origin.y+1, 10, 8) andImage:LOADIMAGE(@"grayHeart@2x") andUserInteractionEnabled:NO];
    [twoView addSubview:clloctionIV];
    
    gemplcollectLB = [UILabel initLabelText:@"85" andRect:CGRectMake(width_x(clloctionIV)+4, gorderCountLB.frame.origin.y, 100, 11) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:11] andTextColor:UIColorFromRGB(0x9d9d9d) andTextAlignment:NSTextAlignmentLeft];
    [twoView addSubview:gemplcollectLB];
    
    
    
    threeView = [UIView initViewRect:CGRectMake(0, height_y(twoView), view2.frame.size.width, 195) andBackGroudColor:mClearColor];
    [view2 addSubview:threeView];

    UILabel * fuzhuanLB = [UILabel initLabelText:@"服装造型" andRect:CGRectMake(0, 0, view2.frame.size.width,48) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:17] andTextColor:UIColorFromRGB(0x4a4a4a) andTextAlignment:NSTextAlignmentCenter];
    [threeView addSubview:fuzhuanLB];
    
    NSArray * arr1 = @[@"4组造型",@"5组造型"];
    for (int i=0;i<2;i++){
        UIButton * btn = [UIButton initButton:CGRectMake(19+(74.5+8)*i, height_y(fuzhuanLB),74.5, 28.5) btnNorImage:LOADIMAGE(@"white_kuang@2x") btnDisableBtn:LOADIMAGE(@"red_kuang@2x") btnTitle:[arr1 objectAtIndex:i] titleNorColor:UIColorFromRGB(0x929292) titleSelectColor:UIColorFromRGB(0x929292) titleFont:[UIFont systemFontOfSize:12]];
        [btn setBackgroundImage:LOADIMAGE(@"white_kuang@2x") forState:UIControlStateHighlighted];
        [btn addTarget:self action:@selector(chooseFuZhuang:) forControlEvents:UIControlEventTouchUpInside];
        [threeView addSubview:btn];
        btn.tag = 10000+i;
        if (i == 0){
            btn.enabled = NO;
        }
    }
    
    UIImageView * l2 = [UIImageView initImageViewRect:CGRectMake(0, height_y(fuzhuanLB)+28.5+15, view2.frame.size.width, 0.5) andImage:LOADIMAGE(@"xuxian_long@2x") andUserInteractionEnabled:YES];
    [threeView addSubview:l2];
    
    UILabel * xianzeLB = [UILabel initLabelText:@"相册" andRect:CGRectMake(0, height_y(l2), view2.frame.size.width, 48) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:17] andTextColor:UIColorFromRGB(0x4a4a4a) andTextAlignment:NSTextAlignmentCenter];
    [threeView addSubview:xianzeLB];
    
    NSArray * arr2 = @[@"要相册",@"不要相册"];
    for (int i=0;i<2;i++){
        UIButton * btn = [UIButton initButton:CGRectMake(19+(74.5+8)*i, height_y(xianzeLB),74.5, 28.5) btnNorImage:LOADIMAGE(@"white_kuang@2x") btnDisableBtn:LOADIMAGE(@"red_kuang@2x") btnTitle:[arr2 objectAtIndex:i] titleNorColor:UIColorFromRGB(0x929292) titleSelectColor:UIColorFromRGB(0x929292) titleFont:[UIFont systemFontOfSize:12]];
        [btn setBackgroundImage:LOADIMAGE(@"white_kuang@2x") forState:UIControlStateHighlighted];
        [btn addTarget:self action:@selector(chooseXianCe:) forControlEvents:UIControlEventTouchUpInside];
        [threeView addSubview:btn];
        btn.tag = 20000+i;
        if(i==0){
            btn.enabled = NO;
        }
    }
    
    UIButton * sureBtn = [UIButton initButton:CGRectMake((view2.frame.size.width-111)/2.0f,view2.frame.size.height-32-20, 111,32) btnImage:LOADIMAGE(@"surexiadanbtn@2x") btnTitle:@"确认下单" titleColor:[UIColor whiteColor] titleFont:[UIFont systemFontOfSize:16]];
    [sureBtn addTarget:self action:@selector(sureBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [view2 addSubview:sureBtn];
    
}

#pragma mark
#pragma mark 选择服装造型
-(void)chooseFuZhuang:(UIButton *)button
{

    UIButton * btn1 = (UIButton *)[threeView viewWithTag:10000];
    UIButton * btn2 = (UIButton *)[threeView viewWithTag:10001];
    
    btn1.enabled = btn1.tag == button.tag?NO:YES;
    btn2.enabled = btn2.tag == button.tag?NO:YES;

    
    UIButton * btn11 = (UIButton *)[threeView viewWithTag:20000];
    UIButton * btn22 = (UIButton *)[threeView viewWithTag:20001];

    if (btn11.enabled == NO){
        if (btn1.enabled == NO){
            [self chickseriesWithModeCount:4 andXCCount:1];
        }else if (btn2.enabled == NO){
            [self chickseriesWithModeCount:5 andXCCount:1];
        }
    }else if (btn22.enabled == NO){
        if (btn1.enabled == NO){
            [self chickseriesWithModeCount:4 andXCCount:0];
        }else if (btn2.enabled == NO){
            [self chickseriesWithModeCount:5 andXCCount:0];
        }
    }
}

#pragma mark
#pragma mark 选择不同规格刷新数据
-(void)chickseriesWithModeCount:(int)a andXCCount:(int)b
{
    for (NSDictionary * dict in SeriesInfoArray){
        if([dict[@"ModeCount"] intValue]==a &&[dict[@"XCCount"] intValue]==b){
            persentSeriesDict =[[NSMutableDictionary alloc] initWithDictionary:dict];
            break;
        }
    }
    [mTableView reloadData];

    zString = [NSString stringWithFormat:@"%d组造型",a];
    if (b==1){
        xString = [NSString stringWithFormat:@"要相册"];
    }else{
        xString = [NSString stringWithFormat:@"不要相册"];
    }
    
    UIView * view = (UIView *)mTableView.tableHeaderView;
    UILabel * NameLabel = (UILabel *)[view viewWithTag:1002];
    NameLabel.text = persentSeriesDict[@"SeriesName"];
    //        UIImageView * headIV = (UIImageView *)[view viewWithTag:1001];
    //        [headIV sd_setImageWithURL:[NSURL URLWithString:persentSeriesDict[@"SeriesPhotoID"]] placeholderImage:nil];
    
    
    gworkNameLB.text = persentSeriesDict[@"SeriesName"];
    
    [gworkIV sd_setImageWithURL:[NSURL URLWithString:persentSeriesDict[@"SeriesPhotoID"]] placeholderImage:nil];
    
    gworkPriceLB.frame=CGRectMake(gworkNameLB.frame.origin.x,height_y(gworkNameLB)+10, 160, 20);
    gworkPriceLB.text = [NSString stringWithFormat:@"￥%@",persentSeriesDict[@"Price"]];
    CGRect rect1 = [XDTools autoSizeOftext:gworkPriceLB.text andSize:CGSizeMake(200, 20.0f) andtextFont:20.0f];
    gworkPriceLB.frame =CGRectMake(gworkNameLB.frame.origin.x,height_y(gworkNameLB)+10,rect1.size.width, 20);
    
    gworkMarketPriceLB.frame = CGRectMake(width_x(gworkPriceLB)+8,gworkPriceLB.frame.origin.y+5, 150, 14);
    gworkMarketPriceLB.text = [NSString stringWithFormat:@"￥%@",persentSeriesDict[@"MarketPrice"]];
    CGRect rect2 = [XDTools autoSizeOftext:gworkMarketPriceLB.text andSize:CGSizeMake(200, 15.0f) andtextFont:15.0f];
    
    lview.frame = CGRectMake(gworkMarketPriceLB.frame.origin.x,gworkMarketPriceLB.center.y, rect2.size.width+4, 1);
}

#pragma mark
#pragma mark  loginViewController Delegate
-(void)lReflashData
{
    [self getDatas];
}

#pragma mark
#pragma mark 选择相册数量
-(void)chooseXianCe:(UIButton *)button
{
    UIButton * btn11 = (UIButton *)[threeView viewWithTag:20000];
    UIButton * btn22 = (UIButton *)[threeView viewWithTag:20001];
    
    btn11.enabled = btn11.tag == button.tag?NO:YES;
    btn22.enabled = btn22.tag == button.tag?NO:YES;
    
    UIButton * btn1 = (UIButton *)[threeView viewWithTag:10000];
    UIButton * btn2 = (UIButton *)[threeView viewWithTag:10001];
    
    if (btn11.enabled== NO){ //要相册
        if (btn1.enabled == NO){
            [self chickseriesWithModeCount:4 andXCCount:1];
        }else if (btn2.enabled == NO){
            [self chickseriesWithModeCount:5 andXCCount:1];
        }
    }else if (btn22.enabled == NO){  //不要相册
        if (btn1.enabled == NO){
            [self chickseriesWithModeCount:4 andXCCount:0];
        }else if (btn2.enabled == NO){
            [self chickseriesWithModeCount:5 andXCCount:0];
        }
    }
}


#pragma mark
#pragma mark 右上角按钮点击事件
-(void)rightBtnCick
{
    ShowRecommendWebViewController * showvc = [[ShowRecommendWebViewController alloc] init];
    [self.navigationController pushViewController:showvc animated:YES];
}

#pragma mark
#pragma mark 选择其他套餐
-(void)chooseOtherTaoCan
{
    [UIView animateWithDuration:backTime animations:^{
        guiGeView.frame = self.view.bounds;
    } completion:^(BOOL finished) {
        
    }];
    
}

#pragma mark
#pragma mark 规格UI动画返回
-(void)guiGeViewBack:(id)sender
{
    if ([sender isKindOfClass:[UITapGestureRecognizer class]]){
        [UIView animateWithDuration:backTime animations:^{
            guiGeView.frame = CGRectMake(UI_SCREEN_WIDTH, 0,self.view.frame.size.width,self.view.frame.size.height);
        } completion:^(BOOL finished) {
            
        }];
    }else if([sender isKindOfClass:[UISwipeGestureRecognizer class]]){
        UISwipeGestureRecognizer * recognizer = sender;
        if (recognizer.direction==UISwipeGestureRecognizerDirectionRight){
            [UIView animateWithDuration:backTime animations:^{
                guiGeView.frame = CGRectMake(UI_SCREEN_WIDTH, 0,self.view.frame.size.width,self.view.frame.size.height);
            } completion:^(BOOL finished) {
                
            }];
        }
    }

}

#pragma mark
#pragma mark 下单或选中该套餐
-(void)sureBtnClick
{
    //套餐价格
    [XDTools sharedXDTools].taocanPrcie = persentSeriesDict[@"Price"];
    //套餐名称
    [XDTools sharedXDTools].taocanName = persentSeriesDict[@"SeriesName"];
    //套餐图片
    [XDTools sharedXDTools].taocanImgUrl = persentSeriesDict[@"SeriesPhotoID"];
    //套餐id
    [XDTools sharedXDTools].SeriesID = persentSeriesDict[@"SeriesID"];
    [XDTools sharedXDTools].taocanMarketPrice = persentSeriesDict[@"MarketPrice"];
    
    //值的存储 -- 摄影师
    [XDTools sharedXDTools].emplImgUrl = EmplInfoDict[@"EmplAvator"];
    [XDTools sharedXDTools].emplLevel = EmplInfoDict[@"LevelName"];
    [XDTools sharedXDTools].emplName = EmplInfoDict[@"EmplName"];
    
    if(ARRAY_IS_NOT_EMPTY(EmplInfoDict[@"ReviewTypeAvg"])){
        [XDTools sharedXDTools].emplZhuanYe = [[EmplInfoDict[@"ReviewTypeAvg"] firstObject] valueForKey:@"Avg"];
        [XDTools sharedXDTools].emplGouTong = [[EmplInfoDict[@"ReviewTypeAvg"] objectAtIndex:1] valueForKey:@"Avg"];
        [XDTools sharedXDTools].emplShoushi = [[EmplInfoDict[@"ReviewTypeAvg"] lastObject] valueForKey:@"Avg"];
        
    }else{
        [XDTools sharedXDTools].emplZhuanYe = nil;
        [XDTools sharedXDTools].emplGouTong =nil;
        [XDTools sharedXDTools].emplShoushi =nil;
        
    }
    
    OrderConfirmViewController * orderconfirmVC = [[OrderConfirmViewController alloc] init];
    [self.navigationController pushViewController:orderconfirmVC animated:YES];
    
}

#pragma mark 
#pragma mark UITableView Delegate
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:
        {
            return 200+33;
        }
            break;
        case 1:
        {
            return 40;
        }
            break;
        case 2:
        {
            return 30;
        }
            break;
        case 3:
        {
            return 88;
        }
            break;
        case 4:
        {
            return 30.5;
        }
            break;
        case 5:
        {
            return 40;
        }
            break;
        default:
            break;
    }
    return 105;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    int a=0;
    if ([PhotoListArray count]%3==0){
        a = [PhotoListArray count]/3;
    }else{
        a = [PhotoListArray count]/3+1;
    }
    return 6+ a;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row){
        case 0:
        {
            static NSString * cellName = @"cell1";
            SynDetailsFirstCell * cell = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (cell == nil){
                cell = [[SynDetailsFirstCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            cell.delegate = self;
            cell.dataDict = persentSeriesDict;
            footPriceLB.text =[NSString stringWithFormat:@"￥%@",persentSeriesDict[@"Price"]];
            return cell;
        }
            break;
        case 1:
        {
            static NSString * cellName = @"cell11";
            SynDetailsSixthCell * cell = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (cell == nil){
                cell = [[SynDetailsSixthCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            cell.zaoxinLB.text = zString;
            cell.xianceLB.text = xString;
            return cell;
        }
            break;
        case 2:
        {
            static NSString * cellName = @"cell2";
            SynDetailsSecondCell * cell = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (cell == nil){
                cell = [[SynDetailsSecondCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;

            }
            return cell;
        }
            break;
        case 3:
        {
            static NSString * cellName = @"cell3";
            SynDetailsThridCell * cell = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (cell == nil){
                cell = [[SynDetailsThridCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;

            }
            cell.delegate = self;
            cell.dataDict = EmplInfoDict;
            cell.isRenZhen = self.isrenzheng;
            
            cell.iscollcetion = iscollcetion;
            cell.collcetioncount = collectioncount;
            
            
            
            return cell;
        }
            break;
        case 4:
        {
            static NSString * cellName = @"cell4";
            StarCell * cell = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (cell == nil){
                cell = [[StarCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;

            }
            cell.starLB.text = EmplInfoDict[@"ReviewAvg"];
            cell.rightLB.text = EmplInfoDict[@"ReviewCount"];
            cell.customNumberOfStars.rating = [EmplInfoDict[@"ReviewAvg"] floatValue];
            
            if ([EmplInfoDict[@"ReviewCount"] intValue]==0){
                cell.customNumberOfStars.rating = 0;
                cell.starLB.hidden = YES;
                cell.rightLB.hidden = YES;
                cell.arrowsIV.hidden =YES;
            }else{
                cell.customNumberOfStars.rating = [EmplInfoDict[@"ReviewAvg"] floatValue];
                cell.starLB.text = EmplInfoDict[@"ReviewAvg"];
                cell.rightLB.text = [NSString stringWithFormat:@"共%@人评价",EmplInfoDict[@"ReviewCount"]];
                cell.starLB.hidden = NO;
                cell.rightLB.hidden = NO;
                cell.arrowsIV.hidden =NO;

            }
            
            [cell resetViewWithSynDtailsVC];
            return cell;
        }
            break;
        case 5:
        {
            static NSString * cellName = @"cell5";
            SynDetailFourthCell * cell = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (cell == nil){
                cell = [[SynDetailFourthCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;

            }
            return cell;
        }
            break;
        default:
            break;
    }
    
    static NSString * cellName0 = @"cell6";
    SynDetailsFifthCell * cell0 = [tableView dequeueReusableCellWithIdentifier:cellName0];
    if (cell0 == nil){
        cell0 = [[SynDetailsFifthCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName0];
        cell0.selectionStyle = UITableViewCellSelectionStyleNone;

    }
    cell0.delegate = self;
    if((indexPath.row-6)*3<[PhotoListArray count]){
        cell0.dataDict1 = [PhotoListArray objectAtIndex:(indexPath.row-6)*3];
    }else{
        cell0.dataDict1 = nil;

    }
    if((indexPath.row-6)*3+1<[PhotoListArray count]){
        cell0.dataDict2 = [PhotoListArray objectAtIndex:(indexPath.row-6)*3+1];
    }else{
        cell0.dataDict2 = nil;
        
    }
    if((indexPath.row-6)*3+2<[PhotoListArray count]){
        cell0.dataDict3 = [PhotoListArray objectAtIndex:(indexPath.row-6)*3+2];
    }else{
        cell0.dataDict3 = nil;
        
    }
    return cell0;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    DDLOG(@"%d",indexPath.row);
    if(indexPath.row == 4){  //评价页
        DDLOG_CURRENT_METHOD;
        if ([EmplInfoDict[@"ReviewCount"] intValue]==0){
            return;
        }
        CommentListViewController * cvc = [[CommentListViewController alloc] init];
        cvc.empleid = EmplInfoDict[@"EmplID"];
        cvc.seriesID = @"";
        [self.navigationController pushViewController:cvc animated:YES];
        
    }else if (indexPath.row==1){   //选择规格
        
        [self chooseOtherTaoCan];
    }
}

#pragma mark
#pragma mark SynDetailsFirstCell Delegate
-(void)iconIvClickWithUrl:(NSString *)mUrlString
{
    if (IS_NOT_EMPTY(persentSeriesDict[@"Url"])){
        ShowWebViewController * showWebVC = [[ShowWebViewController alloc] init];
        showWebVC.urlstring = persentSeriesDict[@"Url"];
        [self.navigationController pushViewController:showWebVC animated:YES];
    }
}

#pragma mark
#pragma mark SynDetailsThirdCell Delegate 收藏或取消收藏
-(void)collectBtnClick:(BOOL)mCollect andbtn:(UIButton *)btn  //yes收藏  no取消收藏
{
    if(ISLOGING){
        btn.userInteractionEnabled = NO;
        [self collectTheTaoCan:mCollect andbtn:btn];
    }else{
        loginViewController * loginVC = [[loginViewController alloc] init];
        loginVC.delegate = self;
        [self.navigationController pushViewController:loginVC animated:YES];
    }
}

#pragma mark
#pragma mark SynDetailsThirdCell Delegate 去摄影师主页
-(void)gotoEmplHomeVCWithEmplID:(NSString *)memplid andEmplName:(NSString *)memplname andEmplImg:(UIImage *)mimage
{
    CameraMameHomePageViewController *camerMameHomePage = [[CameraMameHomePageViewController alloc]init];
    camerMameHomePage.cameraManId = memplid;
    camerMameHomePage.cameraHeaderImage = mimage;
    camerMameHomePage.cameraManName = memplname;
    [self.navigationController pushViewController:camerMameHomePage animated:YES];
}

#pragma mark
#pragma mark SynDetailsFifthCell Delegate 点击小图浏览大图
-(void)browsingLargerImageWithIV:(UIImageView *)mIv andUrl:(NSString *)mUrlString
{
    DDLOG_CURRENT_METHOD;
//    WorksDetailCell * cell = (WorksDetailCell *)[collectionView cellForItemAtIndexPath:indexPath];
    if([PhotoListArray  count]){
        int count = PhotoListArray.count;
        // 1.封装图片数据
        NSMutableArray * photos = [NSMutableArray arrayWithCapacity:count];
        for (int i = 0; i<count; i++) {
            // 替换为中等尺寸图片
            NSString *url = PhotoListArray[i][@"Photo"];
            MJPhoto * photo = [[MJPhoto alloc] init];
            photo.url = [NSURL URLWithString:url]; // 图片路径
            if (i == 0){
                photo.srcImageView =mIv;
            }
            [photos addObject:photo];
            
        }
        int number=0;
        for (int i =0;i<[PhotoListArray count];i++){
            NSDictionary * dict = [PhotoListArray objectAtIndex:i];
            if ([mUrlString isEqualToString:dict[@"Photo"]]){
                number=i;
                break;
            }
        }
        // 2.显示相册
        MJPhotoBrowser * browser = [[MJPhotoBrowser alloc] init];
        browser.currentPhotoIndex =number;
        browser.photos = photos; // 设置所有的图片
        [browser show];
    }
}

#pragma mark
#pragma mark 获取数据
-(void)getDatas
{
    
    if(![XDTools NetworkReachable]){
        mTableView.hidden = YES;
        [XDTools showTips:brokenNetwork toView:self.view];
        return;
    }
    
    NSDictionary * parms = @{@"SceneID":[XDTools sharedXDTools].SceneID,
                             @"CustomerID":[XDTools sharedXDTools].CustomerID,
                             @"EmplID":[XDTools sharedXDTools].EmplID,
                             @"PMID":[XDTools sharedXDTools].ModeID};
    
    ASIHTTPRequest * request = [XDTools postRequestWithDict:parms API:API_getDetail];
    __weak ASIHTTPRequest * mrequest = request;
    [request setCompletionBlock:^{
        [XDTools hideProgress:self.contentView];
        NSDictionary * tmpDict = [XDTools JSonFromString:[mrequest responseString]];
        if ([tmpDict[@"status"] intValue]==1){
            
            if (!(ARRAY_IS_NOT_EMPTY(tmpDict[@"data"][@"SeriesInfo"]))){
                [XDTools showErrorTips:@"暂无套餐" toView:self.view];
                mTableView.hidden =YES;
                footview.hidden =YES;
                return;
            }
            mTableView.hidden = NO;
            footview.hidden = NO;
            
            [PhotoListArray removeAllObjects];
            [SeriesInfoArray removeAllObjects];
            
            EmplInfoDict = tmpDict[@"data"][@"EmplInfo"];  //摄影师信息
            [PhotoListArray addObjectsFromArray:tmpDict[@"data"][@"PhotoList"]];  //套餐图片信息
            [SeriesInfoArray addObjectsFromArray:tmpDict[@"data"][@"SeriesInfo"]]; //套餐信息
            persentSeriesDict = [SeriesInfoArray firstObject];
            
            iscollcetion = [EmplInfoDict[@"IsCollection"] boolValue];
            collectioncount = [EmplInfoDict[@"CollectionCount"] intValue];
            
        }else{
            mTableView.hidden = YES;
            footview.hidden = YES;
            [XDTools showTips:tmpDict[@"msg"] toView:self.view];
        }
        
        UIView * view = (UIView *)mTableView.tableHeaderView;
        UILabel * NameLabel = (UILabel *)[view viewWithTag:1002];
        NameLabel.text = persentSeriesDict[@"SeriesName"];
//        UIImageView * headIV = (UIImageView *)[view viewWithTag:1001];
//        [headIV sd_setImageWithURL:[NSURL URLWithString:persentSeriesDict[@"SeriesPhotoID"]] placeholderImage:nil];

    
        gworkNameLB.text = persentSeriesDict[@"SeriesName"];
  
        [gworkIV sd_setImageWithURL:[NSURL URLWithString:persentSeriesDict[@"SeriesPhotoID"]] placeholderImage:nil];
        [gemplIV sd_setImageWithURL:[NSURL URLWithString:EmplInfoDict[@"EmplAvator"]] placeholderImage:LOADIMAGE(@"placeholderHeader")];
        
        gworkPriceLB.frame=CGRectMake(gworkNameLB.frame.origin.x,height_y(gworkNameLB)+10, 160, 20);
        gworkPriceLB.text = [NSString stringWithFormat:@"￥%@",persentSeriesDict[@"Price"]];
        CGRect rect1 = [XDTools autoSizeOftext:gworkPriceLB.text andSize:CGSizeMake(200, 20.0f) andtextFont:20.0f];
        gworkPriceLB.frame =CGRectMake(gworkNameLB.frame.origin.x,height_y(gworkNameLB)+10,rect1.size.width, 20);
        
        gworkMarketPriceLB.frame = CGRectMake(width_x(gworkPriceLB)+8,gworkPriceLB.frame.origin.y+5, 150, 14);
        gworkMarketPriceLB.text = [NSString stringWithFormat:@"￥%@",persentSeriesDict[@"MarketPrice"]];
        CGRect rect2 = [XDTools autoSizeOftext:gworkMarketPriceLB.text andSize:CGSizeMake(200, 15.0f) andtextFont:15.0f];
        
        lview.frame = CGRectMake(gworkMarketPriceLB.frame.origin.x,gworkMarketPriceLB.center.y, rect2.size.width+4, 1);
        
        gemplNameLB.text = EmplInfoDict[@"EmplName"];
        gemplcollectLB.text = EmplInfoDict[@"CollectionCount"];
        gorderCountLB.text = EmplInfoDict[@"OrderCount"];
        [mTableView reloadData];
    }];
    [request setFailedBlock:^{
        mTableView.hidden = YES;
        footview.hidden = YES;
        [XDTools hideProgress:self.contentView];
        [XDTools showTips:networkovertime toView:self.view];
    }];
    [request startAsynchronous];
    [XDTools showProgress:self.contentView];
    

}

#pragma mark
#pragma mark 提交收藏
-(void)collectTheTaoCan:(BOOL)isCollection andbtn:(UIButton *)btn
{
    if (![XDTools NetworkReachable]){
        [XDTools showTips:networkovertime toView:self.view];
        btn.userInteractionEnabled = YES;
        return;
    }
    NSString * api;
    NSDictionary * parms = @{@"CustomerID":[[NSUserDefaults standardUserDefaults] valueForKey:kMY_USER_ID],
                             @"EmplID":[XDTools sharedXDTools].EmplID,
                             @"SeriesID":persentSeriesDict[@"SeriesID"],
                             @"SceneID":[XDTools sharedXDTools].SceneID,
                             @"Type":@"T"};;
    if (isCollection){
        api = API_COLLECT;
    }else{
        api = API_cancellation;
    }
    
    ASIHTTPRequest * request = [XDTools postRequestWithDict:parms API:api];
    __weak ASIHTTPRequest * mrequest = request;
    [request setCompletionBlock:^{
        NSDictionary * tmpDict = [XDTools JSonFromString:[mrequest responseString]];
        if([[tmpDict objectForKey:@"status"] intValue] == 1){
            [XDTools showTips:[tmpDict valueForKey:@"msg"] toView:self.view];
            
            if (isCollection){
                iscollcetion = YES;
                if ([EmplInfoDict[@"IsCollection"] boolValue]){
                    collectioncount = [EmplInfoDict[@"CollectionCount"] intValue];
                }else{
                    collectioncount = [EmplInfoDict[@"CollectionCount"] intValue]+1;

                }
            }else{
                iscollcetion = NO;
                if ([EmplInfoDict[@"IsCollection"] boolValue]){
                    collectioncount = [EmplInfoDict[@"CollectionCount"] intValue]-1;
                }else{
                    collectioncount = [EmplInfoDict[@"CollectionCount"] intValue];
                }
            }
            NSIndexPath *indexPath1=[NSIndexPath indexPathForRow:3 inSection:0];
            [mTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath1,nil] withRowAnimation:UITableViewRowAnimationNone];
        }else{
            if (IS_NOT_EMPTY([tmpDict valueForKey:@"msg"])){
                [XDTools showTips:[tmpDict valueForKey:@"msg"] toView:self.view];
            }
        }
    }];
    [request setFailedBlock:^{
        [XDTools showTips:networkovertime toView:self.view];
    }];
    [request startAsynchronous];
    
}


//////分享回调方法
-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response
{
    //根据`responseCode`得到发送结果,如果分享成功
    if(response.responseCode == UMSResponseCodeSuccess)
    {
        //得到分享到的微博平台名
        NSString *type = [[response.data allKeys] objectAtIndex:0];
        NSLog(@"share to sns name is %@",[[response.data allKeys] objectAtIndex:0]);
        
        //wxsession  wxtimeline  sina
        [XDTools showTips:@"分享成功" toView:self.contentView];
    }
}



//初始化分享view
-(void)initShareView{
    
    
    window = [[[UIApplication sharedApplication] delegate] window];
    aliphaView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, window.frame.size.height)];
    aliphaView.backgroundColor = [UIColor blackColor];
    aliphaView.alpha = .2f;
    aliphaView.hidden = YES;
    [window addSubview:aliphaView];
    
    UITapGestureRecognizer *alphaTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleAlphaView)];
    [aliphaView addGestureRecognizer:alphaTap];
    
    shareView = [[UIView alloc] initWithFrame:CGRectMake(0,window.frame.size.height , window.frame.size.width, SHAREHEIGHT)];
    shareView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"shareView_back"]];
    
    
    UILabel *shareLabel = [[UILabel alloc] initWithFrame:CGRectMake(138, 12, 52, 18)];
    shareLabel.backgroundColor = [UIColor clearColor];
    shareLabel.font = [UIFont systemFontOfSize:17];
    shareLabel.text = @"分享到";
    shareLabel.textColor = UIColorFromRGB(0x999999);
    [shareView addSubview:shareLabel];
    
    [window addSubview:shareView];
    
    
    
    
    
    
    for (int i = 0; i<3; i++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(35+(60+35)*(i%4), 48+(i/4)*(18+8+20+60), 60, 60);
        button.tag = 100+i;
        [button addTarget:self action:@selector(goToShare:) forControlEvents:UIControlEventTouchUpInside];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(button.frame.origin.x, button.frame.origin.y+button.frame.size.height+8, 60, 18)];
        label.backgroundColor = [UIColor clearColor];
        label.font = [UIFont systemFontOfSize:15];
        label.textColor = UIColorFromRGB(0x666666);
        label.textAlignment = NSTextAlignmentCenter;
        
        [shareView addSubview:button];
        [shareView addSubview:label];
        
        switch (i) {
            case 0:
            {
                [button setBackgroundImage:[UIImage imageNamed:@"weibo_icon"] forState:UIControlStateNormal];
                label.text = @"新浪微博";
            }
                break;
            case 1:
            {
                [button setBackgroundImage:[UIImage imageNamed:@"weixin_icon"] forState:UIControlStateNormal];
                label.text = @"微信";
            }
                break;
            case 2:
            {
                [button setBackgroundImage:[UIImage imageNamed:@"friend_cycle"] forState:UIControlStateNormal];
                label.text = @"朋友圈";
            }
                break;
                
            default:
                break;
        }
        
    }
    
    UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    cancelBtn.frame = CGRectMake(16, shareView.frame.size.height-15-39, 288, 39);
    [cancelBtn setBackgroundImage:[UIImage imageNamed:@"cancel_share"] forState:UIControlStateNormal];
    [cancelBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [cancelBtn addTarget:self action:@selector(handleAlphaView) forControlEvents:UIControlEventTouchUpInside];
    
    [shareView addSubview:cancelBtn];
    
}

//去分享
-(void)goToShare:(UIButton *)button{
    
    BOOL isAccessSina = [UMSocialAccountManager isOauthAndTokenNotExpired:UMShareToSina];
    
    BOOL isAccessQQ = [UMSocialAccountManager isOauthAndTokenNotExpired:UMShareToQQ];
    
    BOOL isAccessQQZone = [UMSocialAccountManager isOauthAndTokenNotExpired:UMShareToQzone];
    
    NSString *qqShareType;
    BOOL qqOauth;
    
    UIImage *shareImage;
    if (shareIm == nil) {
        shareImage = [UIImage imageNamed:@"Icon_ios7"];
    }else{
        shareImage = shareIm;
    }
    
    
    [self handleAlphaView];
    int tag = button.tag - 100;
    
    
    [UMSocialData defaultData].extConfig.title = @"儿童摄影，就找小鬼当佳！";
    
    //设置分享内容和回调对象
    if (tag == 0){
        
        if (shareIm == nil) {
            shareImage = [UIImage imageNamed:@"Icon_ios7"];
        }
        
        [[UMSocialControllerService defaultControllerService] setShareText:[NSString stringWithFormat:@"我家宝贝在小鬼当佳拍照了，找的就是摄影师%@，很不错哦！",EmplInfoDict[@"EmplName"]] shareImage:shareImage socialUIDelegate:self];
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
        
    }else if (tag == 1){
        //微信会话
        [UMSocialData defaultData].extConfig.wechatSessionData.url = [NSString stringWithFormat:@"http://www.meike365.cn/index.php?m=Api&c=Wap&a=sharesyn&EmplID=%@&PMID=%@&SceneID=%@",[XDTools sharedXDTools].EmplID,[XDTools sharedXDTools].ModeID,[XDTools sharedXDTools].SceneID];
        //设置你自己的url地址;
        [[UMSocialControllerService defaultControllerService] setShareText:[NSString stringWithFormat:@"我家宝贝在小鬼当佳拍照了，找的就是摄影师%@，很不错哦！",EmplInfoDict[@"EmplName"]] shareImage:shareImage socialUIDelegate:self];
        UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatSession];
        snsPlatform.snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
        
        
    }else if (tag == 2){
        //朋友圈分享
        [UMSocialData defaultData].extConfig.title = [NSString stringWithFormat:@"我家宝贝在小鬼当佳拍照了，找的就是摄影师%@，很不错哦！",EmplInfoDict[@"EmplName"]];
        
        NSString * url = [NSString stringWithFormat:@"http://www.meike365.cn/index.php?m=Api&c=Wap&a=sharesyn&EmplID=%@&PMID=%@&SceneID=%@",[XDTools sharedXDTools].EmplID,[XDTools sharedXDTools].ModeID,[XDTools sharedXDTools].SceneID];
        
        [UMSocialData defaultData].extConfig.wechatTimelineData.url = [NSString stringWithFormat:@"http://www.meike365.cn/index.php?m=Api&c=Wap&a=sharesyn&EmplID=%@&PMID=%@&SceneID=%@",[XDTools sharedXDTools].EmplID,[XDTools sharedXDTools].ModeID,[XDTools sharedXDTools].SceneID]; //设置你自己的url地址;
        
        [[UMSocialControllerService defaultControllerService] setShareText:nil shareImage:shareImage socialUIDelegate:self];
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatTimeline].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
    }
}




#pragma mark 分享
- (void)handleAlphaView{
    if (aliphaView.hidden) {
        aliphaView.hidden = NO;
        [UIView animateWithDuration:.3 animations:^{
            
            shareView.frame = CGRectMake(0,window.frame.size.height-SHAREHEIGHT , window.frame.size.width, SHAREHEIGHT);
            
            
        }];
    }else{
        aliphaView.hidden = YES;
        [UIView animateWithDuration:.3 animations:^{
            shareView.frame = CGRectMake(0,window.frame.size.height , window.frame.size.width, SHAREHEIGHT);
        }];
    }
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
